package com.yupi.usercenter.common;

import lombok.Data;

import java.io.Serial;
import java.io.Serializable;

/**
 * 通用返回类
 * @author lanzik
 * @param <T>
 */
@Data
public class BaseResponse<T> implements Serializable {
    @Serial
    private static final long serialVersionUID = 4609731815226795649L;
    private int code;
    private String msg;
    private T data;
    private String description;
    public BaseResponse(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public BaseResponse(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public BaseResponse( String description, String msg) {
        this.description = description;
        this.msg = msg;
    }

    public BaseResponse(int code, String msg, String description) {
        this.code = code;
        this.msg = msg;
        this.description = description;
    }

    public BaseResponse(ErrorCode errorCode) {
        this(errorCode.getCode(),errorCode.getMsg(),errorCode.getDescription());
    }
    public BaseResponse(ErrorCode errorCode,String msg,String description) {
        this(errorCode.getCode(),msg,description);
    }
}
